package cn.rick.service.impl;

import cn.rick.entity.SysDept;
import cn.rick.mapper.SysDeptMapper;
import cn.rick.service.ISysDeptService;
import cn.rick.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 部门表 服务实现类
 * </p>
 *
 * @author house_store
 * @since 2022-10-19 14:39:46
 */
@Service
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {

    @Override
    public List<SysDept> selectAllByParam(SysDept sysDept) {
        LambdaQueryWrapper<SysDept> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByAsc(SysDept::getOrderNum);
        if (StringUtils.isNotEmpty(sysDept.getDeptName())) {
            queryWrapper.like(SysDept::getDeptName, sysDept.getDeptName());
        }
        if (StringUtils.isNotEmpty(sysDept.getStatus())) {
            queryWrapper.eq(SysDept::getStatus, sysDept.getStatus());
        }
        return baseMapper.selectList(queryWrapper);
    }
}
